<%--
  Created by IntelliJ IDEA.
  User: SH-T-C-Public
  Date: 2021/12/20
  Time: 17:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<html>
<head>
    <title>查询学生</title>
    <base href="<%=basePath%>">
    <script type="text/javascript" src="jquery3.5.1/jquery-3.5.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            queryAll();
        })
        function queryAll() {
            $.ajax({
                type: "get",
                url: "student/queryStudent.do",
                dataType: "json",
                success: function (data) {
                    // alert(data);
                    //清除旧数据
                    $("#info").html("");
                    //查询数据
                    $.each(data, function (i, n) {
                        $("#info").append("<tr>")
                            .append("<td>" + n.id + "</td>")
                            .append("<td>" + n.name + "</td>")
                            .append("<td>" + n.age + "</td>")
                        .append("</tr>")
                    });
                }
            })
        }
    </script>
</head>
<body>
<div align="center">
    <table>
        <thead>
        <tr>
            <td>学号</td>
            <td>姓名</td>
            <td>年龄</td>
        </tr>
        </thead>
        <tbody id="info">

        </tbody>
    </table>
<%--    <input type="button" id="btn1" value="查询数据1">--%>
    <input type="button" id="btn2" value="查询数据2" onclick="queryAll()">
</div>
</body>
</html>
